const path = require('path');
const sqlConfig = require('./sqlConfig')
console.log(sqlConfig, '------------')
module.exports = appInfo => {
  const config = {};
  // 日志输出
  config.logger = {
    dir: path.join(__dirname, '../logs'),
    appLogName: `${appInfo.name}-web.log`,
    coreLogName: 'egg-web.log',
    agentLogName: 'egg-agent.log',
    errorLogName: 'common-error.log',
    level: 'DEBUG'
  };
  // // 日志分级
  // config.logrotator = {
  //   filesRotateByHour: [
  //     path.join(appInfo.root, 'logs', appInfo.name, `${appInfo.name}-web.log`),
  //   ],
  // }

  config.sequelize = {
    datasources: [
      {
        delegate: 'model',
        dialect: 'mysql', // support: mysql, mariadb, postgres, mssql
        dialectOptions: {
          charset: 'utf8mb4',
        },
        port: 33070,
        host: '121.43.119.235',
        username: 'jrdev',
        password: 'M6KWEkE18wS9D2M',
        database: 'jinr_hd',
        connectionLimit: 50,
        timezone: '+08:00'

      },
      //   { // 本地
      //   delegate:'model',
      //   dialect: 'mysql', // support: mysql, mariadb, postgres, mssql
      //   dialectOptions: {
      //     charset: 'utf8mb4',
      //   },
      //   port: 3306,
      //   host: '127.0.0.1',
      //   username: 'root',
      //   password: '123456',
      //   database: 'jinr_hd',
      //   connectionLimit: 50,
      //   timezone: '+08:00'

      // },

      {
        delegate: 'appModel',
        dialect: 'mysql', // support: mysql, mariadb, postgres, mssql
        dialectOptions: {
          charset: 'utf8mb4',
        },
        port: 33070,
        host: '121.43.119.235',
        username: 'jrdev',
        password: 'M6KWEkE18wS9D2M',
        database: 'jinr_sys',
        connectionLimit: 50,
        timezone: '+08:00'
      }]
  };

  config.redis = {
    client: {
      host: '121.43.119.235',
      port: 63790,
      password: 'JINRdev123',
      db: 254,
    },
  };
  config.oss = {
    accessKeyId: 'LTAIgepekT9v9DyC',
    accessKeySecret: 'pLMVxsKpueeSDa5kfSsIbcc3XfJtiX',
    // jinrvipdev
    // bucket: "jinrfedev", // jinrfedev  jinrfepre jinrfebeta
    bucket: 'jinrfedev',
    region: 'oss-cn-hangzhou',
  };

  // 主站开发机接口地址
  config.appDomain = 'http://jinrapp.dev.jinr.com'
  config.alinode = {// 开发机
    appid: '78086',
    secret: '49e117f7944ea567d782616059fbed7a98f85c41',
    logdir: path.join(__dirname, '../logs')
  };

  return config
}